import com.fasterxml.jackson.databind.ObjectMapper;

import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-03-17
 * Time: 15:16
 */
class Student{
    public int studentId;
    public int classId;
}
@WebServlet("/postParameter2")
public class PostParameter2Servlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//          int length = req.getContentLength();
//          byte[] buffer = new byte[length];
//        InputStream inputStream = req.getInputStream();
//        inputStream.read(buffer);
//        String body = new String(buffer,0,length,"utf8");
//        System.out.println("body = " + body);
          ObjectMapper objectMapper = new ObjectMapper();
        Student student = objectMapper.readValue(req.getInputStream(),Student.class);
        System.out.println(student.studentId+"," +student.classId);
//        resp.getWriter().write(body);
    }
}
